package com.gc.services.impl;


import com.gc.common.util.MyUtil;
import com.gc.dao.custom.MenuTwoMapper;
import com.gc.dao.custom.UserAssociationMapper;
import com.gc.pojo.SysMenuOne;
import com.gc.pojo.SysUserAssociation;
import com.gc.services.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MenuServiceImpl implements MenuService {
    @Autowired
    private MenuTwoMapper menuMapper;
    @Autowired
    private UserAssociationMapper userAssociationMapper;
    @Autowired
    private MyUtil myUtil;
    @Override
    public List<SysMenuOne> getMyMenus(Integer uid) {
        SysUserAssociation association = userAssociationMapper.selectByUid(uid);
        String menuOnes = association.getMenusOne();
        String menuTwos = association.getMenusTwo();
        List<Integer> ones = myUtil.split(menuOnes);
        List<Integer> twos = myUtil.split(menuTwos);
        return menuMapper.selectMenusByMIds(ones,twos);
    }
}
